package com.xkdx.guangguang.fragment.my.setup;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import wealk.android.jewels.JewelsHome;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.xkdx.caipiao.R;
import com.xkdx.guangguang.ManagerActivity;
import com.xkdx.guangguang.fragment.BaseFragment;
import com.xkdx.guangguang.fragment.my.setup.ExchangeShopModule.ProdecuListDetail;
import com.xkdx.guangguang.fragment.my.setup.ExchangeShopModule.ProductListInfo;
import com.xkdx.guangguang.module.network.AbsModule;

public class ExchangeShopFragment extends BaseFragment implements
		OnClickListener {

	Button back, refresh;
	ImageView shop, food, entertement, lift, focusImage;
	RelativeLayout shop_ll, food_ll, entertaiment_ll, life_ll;
	TextView number_shop, number_entertainment, number_food, number_life;

	ImageLoader imageLoader = ImageLoader.getInstance();
	DisplayImageOptions options;
	View view;
	ScrollView sv_myshopingmall;

	public static List<ProdecuListDetail> shopProductList = new ArrayList<ExchangeShopModule.ProdecuListDetail>(),
			entertaimentProductList = new ArrayList<ExchangeShopModule.ProdecuListDetail>(),
			foodProductList = new ArrayList<ExchangeShopModule.ProdecuListDetail>(),
			lifeProductList = new ArrayList<ExchangeShopModule.ProdecuListDetail>();
	ExchangeShopAction exchangeShopAction;
	ExchangeShopModule exchangeShopModule;
	ExchangeShopPresistence exchangeShopPresistence;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		options = new DisplayImageOptions.Builder()
				.showStubImage(R.drawable.empty_photo)
				.showImageForEmptyUri(R.drawable.empty_photo)
				.showImageOnFail(R.drawable.empty_photo)
				.resetViewBeforeLoading().cacheOnDisc()
				.imageScaleType(ImageScaleType.EXACTLY)
				.bitmapConfig(Bitmap.Config.RGB_565).build();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		view = inflater.inflate(R.layout.my_setup_exchangeshop, container,
				false);
		findView();
		setOnClick();
		showLoading();
		return view;
	}

	@Override
	public void showLoading() {
		dataLoadDialog.show();
		exchangeShopPresistence = new ExchangeShopPresistence(this);
		exchangeShopPresistence.setActitons(exchangeShopAction);
		exchangeShopPresistence.setModule(exchangeShopModule);
		exchangeShopPresistence.execute();
		dataLoadDialog.setOnCancelListener(new OnCancelListener() {

			@Override
			public void onCancel(DialogInterface dialog) {
				if (exchangeShopPresistence != null) {
					exchangeShopPresistence.cancel(true);
				}
				getFragmentManager().popBackStack();

			}
		});
		dataLoadDialog.show();
	}

	protected void setShopValue(List<ProdecuListDetail> shopProductList) {
		// shop
		if (shopProductList.size() >= 1) {
			View view1 = view.findViewById(R.id.classification_1);
			view1.setVisibility(View.VISIBLE);
			ImageView im1 = (ImageView) view1.findViewById(R.id.brand_image);
			TextView tv1 = (TextView) view1.findViewById(R.id.brand_item_name);
			tv1.setText(shopProductList.get(0).getProductName());
			imageLoader.displayImage(shopProductList.get(0).getLogo(), im1,
					options);
			setImageClick(im1, shopProductList, 0);

			View view2 = view.findViewById(R.id.classification_2);
			view2.setVisibility(View.INVISIBLE);

			View view3 = view.findViewById(R.id.classification_3);
			view3.setVisibility(View.INVISIBLE);

			View view4 = view.findViewById(R.id.classification_4);
			view4.setVisibility(View.INVISIBLE);
		}
		if (shopProductList.size() >= 2) {
			View view2 = view.findViewById(R.id.classification_2);
			view2.setVisibility(View.VISIBLE);
			ImageView im2 = (ImageView) view2.findViewById(R.id.brand_image);
			TextView tv2 = (TextView) view2.findViewById(R.id.brand_item_name);
			tv2.setText(shopProductList.get(1).getProductName());
			imageLoader.displayImage(shopProductList.get(1).getLogo(), im2,
					options);
			setImageClick(im2, shopProductList, 1);
		}

		if (shopProductList.size() >= 3) {
			View view3 = view.findViewById(R.id.classification_3);
			view3.setVisibility(View.VISIBLE);
			ImageView im3 = (ImageView) view3.findViewById(R.id.brand_image);
			TextView tv3 = (TextView) view3.findViewById(R.id.brand_item_name);
			tv3.setText(shopProductList.get(2).getProductName());
			imageLoader.displayImage(shopProductList.get(2).getLogo(), im3,
					options);
			setImageClick(im3, shopProductList, 2);
		}

		if (shopProductList.size() >= 4) {
			View view4 = view.findViewById(R.id.classification_4);
			view4.setVisibility(View.VISIBLE);
			ImageView im4 = (ImageView) view4.findViewById(R.id.brand_image);
			TextView tv4 = (TextView) view4.findViewById(R.id.brand_item_name);
			tv4.setText(shopProductList.get(3).getProductName());
			imageLoader.displayImage(shopProductList.get(3).getLogo(), im4,
					options);
			setImageClick(im4, shopProductList, 3);
		}

		if (shopProductList.size() >= 5) {
			View view5 = view.findViewById(R.id.classification_5);
			view5.setVisibility(View.VISIBLE);
			ImageView im5 = (ImageView) view5.findViewById(R.id.brand_image);
			TextView tv5 = (TextView) view5.findViewById(R.id.brand_item_name);
			tv5.setText(shopProductList.get(4).getProductName());
			imageLoader.displayImage(shopProductList.get(4).getLogo(), im5,
					options);
			setImageClick(im5, shopProductList, 4);

			View view6 = view.findViewById(R.id.classification_6);
			view6.setVisibility(View.INVISIBLE);

			View view7 = view.findViewById(R.id.classification_7);
			view7.setVisibility(View.INVISIBLE);

			View view8 = view.findViewById(R.id.classification_8);
			view8.setVisibility(View.INVISIBLE);
		}
		if (shopProductList.size() >= 6) {
			View view6 = view.findViewById(R.id.classification_6);
			view6.setVisibility(View.VISIBLE);
			ImageView im6 = (ImageView) view6.findViewById(R.id.brand_image);
			TextView tv6 = (TextView) view6.findViewById(R.id.brand_item_name);
			tv6.setText(shopProductList.get(5).getProductName());
			imageLoader.displayImage(shopProductList.get(5).getLogo(), im6,
					options);
			setImageClick(im6, shopProductList, 5);
		}

		if (shopProductList.size() >= 7) {
			View view7 = view.findViewById(R.id.classification_7);
			view7.setVisibility(View.VISIBLE);
			ImageView im7 = (ImageView) view7.findViewById(R.id.brand_image);
			TextView tv7 = (TextView) view7.findViewById(R.id.brand_item_name);
			tv7.setText(shopProductList.get(6).getProductName());
			imageLoader.displayImage(shopProductList.get(6).getLogo(), im7,
					options);
			setImageClick(im7, shopProductList, 6);
		}
		if (shopProductList.size() >= 8) {
			View view8 = view.findViewById(R.id.classification_8);
			view8.setVisibility(View.VISIBLE);
			ImageView im8 = (ImageView) view8.findViewById(R.id.brand_image);
			TextView tv8 = (TextView) view8.findViewById(R.id.brand_item_name);
			tv8.setText(shopProductList.get(7).getProductName());
			imageLoader.displayImage(shopProductList.get(7).getLogo(), im8,
					options);
			setImageClick(im8, shopProductList, 7);
		}

	}

	protected void setLifeValue(List<ProdecuListDetail> lifeProductList) {
		if (lifeProductList.size() >= 1) {
			View view1 = view.findViewById(R.id.life_1);
			view1.setVisibility(View.VISIBLE);
			ImageView im1 = (ImageView) view1.findViewById(R.id.brand_image);
			TextView tv1 = (TextView) view1.findViewById(R.id.brand_item_name);
			tv1.setText(lifeProductList.get(0).getProductName());
			imageLoader.displayImage(lifeProductList.get(0).getLogo(), im1,
					options);
			setImageClick(im1, lifeProductList, 0);

			View view2 = view.findViewById(R.id.life_2);
			view2.setVisibility(View.INVISIBLE);
			View view3 = view.findViewById(R.id.life_3);
			view3.setVisibility(View.INVISIBLE);
			View view4 = view.findViewById(R.id.life_4);
			view4.setVisibility(View.INVISIBLE);
		}

		if (lifeProductList.size() >= 2) {
			View view2 = view.findViewById(R.id.life_2);
			view2.setVisibility(View.VISIBLE);
			ImageView im2 = (ImageView) view2.findViewById(R.id.brand_image);
			TextView tv2 = (TextView) view2.findViewById(R.id.brand_item_name);
			tv2.setText(lifeProductList.get(1).getProductName());
			imageLoader.displayImage(lifeProductList.get(1).getLogo(), im2,
					options);
			setImageClick(im2, lifeProductList, 1);
		}

		if (lifeProductList.size() >= 3) {
			View view3 = view.findViewById(R.id.life_3);
			view3.setVisibility(View.VISIBLE);
			ImageView im3 = (ImageView) view3.findViewById(R.id.brand_image);
			TextView tv3 = (TextView) view3.findViewById(R.id.brand_item_name);
			tv3.setText(lifeProductList.get(2).getProductName());
			imageLoader.displayImage(lifeProductList.get(2).getLogo(), im3,
					options);
			setImageClick(im3, lifeProductList, 2);
		}

		if (lifeProductList.size() >= 4) {
			View view4 = view.findViewById(R.id.life_4);
			view4.setVisibility(View.VISIBLE);
			ImageView im4 = (ImageView) view4.findViewById(R.id.brand_image);
			TextView tv4 = (TextView) view4.findViewById(R.id.brand_item_name);
			tv4.setText(lifeProductList.get(3).getProductName());
			imageLoader.displayImage(lifeProductList.get(3).getLogo(), im4,
					options);
			setImageClick(im4, lifeProductList, 3);
		}
		if (lifeProductList.size() >= 5) {
			View view5 = view.findViewById(R.id.life_5);
			view5.setVisibility(View.VISIBLE);
			ImageView im5 = (ImageView) view5.findViewById(R.id.brand_image);
			TextView tv5 = (TextView) view5.findViewById(R.id.brand_item_name);
			tv5.setText(lifeProductList.get(4).getProductName());
			imageLoader.displayImage(lifeProductList.get(4).getLogo(), im5,
					options);
			setImageClick(im5, lifeProductList, 4);

			View view6 = view.findViewById(R.id.life_6);
			view6.setVisibility(View.INVISIBLE);

			View view7 = view.findViewById(R.id.life_7);
			view7.setVisibility(View.INVISIBLE);

			View view8 = view.findViewById(R.id.life_8);
			view8.setVisibility(View.INVISIBLE);
		}
		if (lifeProductList.size() >= 6) {
			View view6 = view.findViewById(R.id.life_6);
			view6.setVisibility(View.VISIBLE);
			ImageView im6 = (ImageView) view6.findViewById(R.id.brand_image);
			TextView tv6 = (TextView) view6.findViewById(R.id.brand_item_name);
			tv6.setText(lifeProductList.get(5).getProductName());
			imageLoader.displayImage(lifeProductList.get(5).getLogo(), im6,
					options);
			setImageClick(im6, lifeProductList, 5);
		}
		if (lifeProductList.size() >= 7) {
			View view7 = view.findViewById(R.id.life_7);
			view7.setVisibility(View.VISIBLE);
			ImageView im7 = (ImageView) view7.findViewById(R.id.brand_image);
			TextView tv7 = (TextView) view7.findViewById(R.id.brand_item_name);
			tv7.setText(lifeProductList.get(6).getProductName());
			imageLoader.displayImage(lifeProductList.get(6).getLogo(), im7,
					options);
			setImageClick(im7, lifeProductList, 6);
		}
		if (lifeProductList.size() >= 8) {
			View view8 = view.findViewById(R.id.life_8);
			view8.setVisibility(View.VISIBLE);
			ImageView im8 = (ImageView) view8.findViewById(R.id.brand_image);
			TextView tv8 = (TextView) view8.findViewById(R.id.brand_item_name);
			tv8.setText(lifeProductList.get(7).getProductName());
			imageLoader.displayImage(lifeProductList.get(7).getLogo(), im8,
					options);
			setImageClick(im8, lifeProductList, 7);
		}

	}

	protected void setEntertainmentValue(
			List<ProdecuListDetail> entertaimentProductList) {

		if (entertaimentProductList.size() >= 1) {
			View view1 = view.findViewById(R.id.entertainment_1);
			view1.setVisibility(View.VISIBLE);
			ImageView im1 = (ImageView) view1.findViewById(R.id.brand_image);
			TextView tv1 = (TextView) view1.findViewById(R.id.brand_item_name);
			tv1.setText(entertaimentProductList.get(0).getProductName());
			imageLoader.displayImage(entertaimentProductList.get(0).getLogo(),
					im1, options);
			setImageClick(im1, entertaimentProductList, 0);

			View view2 = view.findViewById(R.id.entertainment_2);
			view2.setVisibility(View.INVISIBLE);
			View view3 = view.findViewById(R.id.entertainment_3);
			view3.setVisibility(View.INVISIBLE);
			View view4 = view.findViewById(R.id.entertainment_4);
			view4.setVisibility(View.INVISIBLE);

		}
		if (entertaimentProductList.size() >= 2) {
			View view2 = view.findViewById(R.id.entertainment_2);
			view2.setVisibility(View.VISIBLE);
			ImageView im2 = (ImageView) view2.findViewById(R.id.brand_image);
			TextView tv2 = (TextView) view2.findViewById(R.id.brand_item_name);
			tv2.setText(entertaimentProductList.get(1).getProductName());
			imageLoader.displayImage(entertaimentProductList.get(1).getLogo(),
					im2, options);
			setImageClick(im2, entertaimentProductList, 1);
		}
		if (entertaimentProductList.size() >= 3) {
			View view3 = view.findViewById(R.id.entertainment_3);
			view3.setVisibility(View.VISIBLE);
			ImageView im3 = (ImageView) view3.findViewById(R.id.brand_image);
			TextView tv3 = (TextView) view3.findViewById(R.id.brand_item_name);
			tv3.setText(entertaimentProductList.get(2).getProductName());
			imageLoader.displayImage(entertaimentProductList.get(2).getLogo(),
					im3, options);
			setImageClick(im3, entertaimentProductList, 2);
		}

		if (entertaimentProductList.size() >= 4) {
			View view4 = view.findViewById(R.id.entertainment_4);
			view4.setVisibility(View.VISIBLE);
			ImageView im4 = (ImageView) view4.findViewById(R.id.brand_image);
			TextView tv4 = (TextView) view4.findViewById(R.id.brand_item_name);
			tv4.setText(entertaimentProductList.get(3).getProductName());
			imageLoader.displayImage(entertaimentProductList.get(3).getLogo(),
					im4, options);
			setImageClick(im4, entertaimentProductList, 3);
		}
		if (entertaimentProductList.size() >= 5) {
			View view5 = view.findViewById(R.id.entertainment_5);
			view5.setVisibility(View.VISIBLE);
			ImageView im5 = (ImageView) view5.findViewById(R.id.brand_image);
			TextView tv5 = (TextView) view5.findViewById(R.id.brand_item_name);
			tv5.setText(entertaimentProductList.get(4).getProductName());
			imageLoader.displayImage(entertaimentProductList.get(4).getLogo(),
					im5, options);
			setImageClick(im5, entertaimentProductList, 4);

			View view6 = view.findViewById(R.id.entertainment_6);
			view6.setVisibility(View.INVISIBLE);

			View view7 = view.findViewById(R.id.entertainment_7);
			view7.setVisibility(View.INVISIBLE);

			View view8 = view.findViewById(R.id.entertainment_8);
			view8.setVisibility(View.INVISIBLE);

		}
		if (entertaimentProductList.size() >= 6) {
			View view6 = view.findViewById(R.id.entertainment_6);
			view6.setVisibility(View.VISIBLE);
			ImageView im6 = (ImageView) view6.findViewById(R.id.brand_image);
			TextView tv6 = (TextView) view6.findViewById(R.id.brand_item_name);
			tv6.setText(entertaimentProductList.get(5).getProductName());
			imageLoader.displayImage(entertaimentProductList.get(5).getLogo(),
					im6, options);
			setImageClick(im6, entertaimentProductList, 5);
		}
		if (entertaimentProductList.size() >= 7) {
			View view7 = view.findViewById(R.id.entertainment_7);
			view7.setVisibility(View.VISIBLE);
			ImageView im7 = (ImageView) view7.findViewById(R.id.brand_image);
			TextView tv7 = (TextView) view7.findViewById(R.id.brand_item_name);
			tv7.setText(entertaimentProductList.get(6).getProductName());
			imageLoader.displayImage(entertaimentProductList.get(6).getLogo(),
					im7, options);
			setImageClick(im7, entertaimentProductList, 6);
		}
		if (entertaimentProductList.size() >= 8) {
			View view8 = view.findViewById(R.id.entertainment_8);
			view8.setVisibility(View.VISIBLE);
			ImageView im8 = (ImageView) view8.findViewById(R.id.brand_image);
			TextView tv8 = (TextView) view8.findViewById(R.id.brand_item_name);
			tv8.setText(entertaimentProductList.get(7).getProductName());
			imageLoader.displayImage(entertaimentProductList.get(7).getLogo(),
					im8, options);
			setImageClick(im8, entertaimentProductList, 7);
		}

	}

	protected void setFoodValue(List<ProdecuListDetail> foodProductList) {
		if (foodProductList.size() >= 1) {

			View view1 = view.findViewById(R.id.food_1);
			view1.setVisibility(View.VISIBLE);
			ImageView im1 = (ImageView) view1.findViewById(R.id.brand_image);
			TextView tv1 = (TextView) view1.findViewById(R.id.brand_item_name);
			if (foodProductList.get(0).getProductName() != null
					&& !("").equals(foodProductList.get(0).getProductName())) {
				tv1.setText(foodProductList.get(0).getProductName());
			} else {
				tv1.setText("");
			}
			imageLoader.displayImage(foodProductList.get(0).getLogo(), im1,
					options);
			setImageClick(im1, foodProductList, 0);

			View view2 = view.findViewById(R.id.food_2);
			view2.setVisibility(View.INVISIBLE);
			View view3 = view.findViewById(R.id.food_3);
			view3.setVisibility(View.INVISIBLE);
			View view4 = view.findViewById(R.id.food_4);
			view4.setVisibility(View.INVISIBLE);
		}

		if (foodProductList.size() >= 2) {
			View view2 = view.findViewById(R.id.food_2);
			view2.setVisibility(View.VISIBLE);
			ImageView im2 = (ImageView) view2.findViewById(R.id.brand_image);
			TextView tv2 = (TextView) view2.findViewById(R.id.brand_item_name);
			if (foodProductList.get(1).getProductName() != null
					&& !("").equals(foodProductList.get(1).getProductName())) {
				tv2.setText(foodProductList.get(1).getProductName());
			} else {
				tv2.setText("");
			}
			imageLoader.displayImage(foodProductList.get(1).getLogo(), im2,
					options);
			setImageClick(im2, foodProductList, 1);
		}
		if (foodProductList.size() >= 3) {
			View view3 = view.findViewById(R.id.food_3);
			view3.setVisibility(View.VISIBLE);
			ImageView im3 = (ImageView) view3.findViewById(R.id.brand_image);
			TextView tv3 = (TextView) view3.findViewById(R.id.brand_item_name);
			if (foodProductList.get(2).getProductName() != null
					&& !("").equals(foodProductList.get(2).getProductName())) {
				tv3.setText(foodProductList.get(2).getProductName());
			} else {
				tv3.setText("");
			}
			imageLoader.displayImage(foodProductList.get(2).getLogo(), im3,
					options);
			setImageClick(im3, foodProductList, 2);
		}

		if (foodProductList.size() >= 4) {
			View view4 = view.findViewById(R.id.food_4);
			view4.setVisibility(View.VISIBLE);
			ImageView im4 = (ImageView) view4.findViewById(R.id.brand_image);
			TextView tv4 = (TextView) view4.findViewById(R.id.brand_item_name);
			if (foodProductList.get(3).getProductName() != null
					&& !("").equals(foodProductList.get(3).getProductName())) {
				tv4.setText(foodProductList.get(3).getProductName());
			} else {
				tv4.setText("");
			}
			imageLoader.displayImage(foodProductList.get(3).getLogo(), im4,
					options);
			setImageClick(im4, foodProductList, 3);
		}

		if (foodProductList.size() >= 5) {
			View view5 = view.findViewById(R.id.food_5);
			view5.setVisibility(View.VISIBLE);
			ImageView im5 = (ImageView) view5.findViewById(R.id.brand_image);
			TextView tv5 = (TextView) view5.findViewById(R.id.brand_item_name);
			if (foodProductList.get(4).getProductName() != null
					&& !("").equals(foodProductList.get(4).getProductName())) {
				tv5.setText(foodProductList.get(4).getProductName());
			} else {
				tv5.setText("");
			}
			imageLoader.displayImage(foodProductList.get(4).getLogo(), im5,
					options);
			setImageClick(im5, foodProductList, 4);

			View view6 = view.findViewById(R.id.food_6);
			view6.setVisibility(View.INVISIBLE);

			View view7 = view.findViewById(R.id.food_7);
			view7.setVisibility(View.INVISIBLE);

			View view8 = view.findViewById(R.id.food_8);
			view8.setVisibility(View.INVISIBLE);

		}

		if (foodProductList.size() >= 6) {
			View view6 = view.findViewById(R.id.food_6);
			view6.setVisibility(View.VISIBLE);
			ImageView im6 = (ImageView) view6.findViewById(R.id.brand_image);
			TextView tv6 = (TextView) view6.findViewById(R.id.brand_item_name);
			if (foodProductList.get(5).getProductName() != null
					&& !("").equals(foodProductList.get(5).getProductName())) {
				tv6.setText(foodProductList.get(5).getProductName());
			} else {
				tv6.setText("");
			}
			imageLoader.displayImage(foodProductList.get(5).getLogo(), im6,
					options);
			setImageClick(im6, foodProductList, 5);
		}

		if (foodProductList.size() >= 7) {
			View view7 = view.findViewById(R.id.food_7);
			view7.setVisibility(View.VISIBLE);
			ImageView im7 = (ImageView) view7.findViewById(R.id.brand_image);
			TextView tv7 = (TextView) view7.findViewById(R.id.brand_item_name);
			if (foodProductList.get(6).getProductName() != null
					&& !("").equals(foodProductList.get(6).getProductName())) {
				tv7.setText(foodProductList.get(6).getProductName());
			} else {
				tv7.setText("");
			}
			imageLoader.displayImage(foodProductList.get(6).getLogo(), im7,
					options);
			setImageClick(im7, foodProductList, 6);
		}

		if (foodProductList.size() >= 8) {
			View view8 = view.findViewById(R.id.food_8);
			view8.setVisibility(View.VISIBLE);
			ImageView im8 = (ImageView) view8.findViewById(R.id.brand_image);
			TextView tv8 = (TextView) view8.findViewById(R.id.brand_item_name);
			if (foodProductList.get(7).getProductName() != null
					&& !("").equals(foodProductList.get(7).getProductName())) {
				tv8.setText(foodProductList.get(7).getProductName());
			} else {
				tv8.setText("");
			}
			imageLoader.displayImage(foodProductList.get(7).getLogo(), im8,
					options);
			setImageClick(im8, foodProductList, 7);
		}

	}

	private void setImageClick(ImageView im,
			final List<ProdecuListDetail> ProductList, final int position) {
		im.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

				FragmentTransaction ft = getFragmentManager()
						.beginTransaction();
				MyIntegralexChangeFrament mychangeFragment = new MyIntegralexChangeFrament();
				Bundle b = new Bundle();
				b.putString("ProductID", ProductList.get(position)
						.getProductID());
				b.putString("Type", ProductList.get(position).getType());
				mychangeFragment.setArguments(b);
				ft.replace(R.id.fragment, mychangeFragment);
				ft.addToBackStack(null);
				ft.commit();

			}
		});
	}

	OnClickListener click = new OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.brand_classification_shop_ll:
				IntentMoreBrand("购物类商品");
				break;
			case R.id.brand_classification_food_ll:
				IntentMoreBrand("美食类商品");
				break;
			case R.id.brand_classification_entertaiment_ll:
				IntentMoreBrand("娱乐类商品");
				break;
			case R.id.brand_classification_life_ll:
				IntentMoreBrand("生活类商品");
				break;

			default:
				break;
			}

		}
	};

	protected void IntentMoreBrand(String tag) {
		FragmentTransaction ft = getFragmentManager().beginTransaction();
		MoreExchangeFragment moreExchangeFragment = new MoreExchangeFragment();
		Bundle b = new Bundle();
		b.putString("tag", tag);
		moreExchangeFragment.setArguments(b);
		ft.replace(R.id.fragment, moreExchangeFragment);
		ft.addToBackStack(null);
		ft.commit();
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.my_shopingchange_refresh:
			showLoading();
			break;

		case R.id.my_shopingchange_imfocus:
			if (getActivity() != null) {
				Intent intent = new Intent(getActivity(), JewelsHome.class);
				startActivity(intent);
			}
			break;
		default:

			break;
		}
	}

	@Override
	public void showLoaded(HashMap<String, AbsModule> map) {
		dataLoadDialog.dismiss();
		if (map.containsKey("0")) {
			setList(exchangeShopModule.productListInfo);
		} else {
			refresh(map);
		}

	}

	@Override
	public void showClick(HashMap<String, AbsModule> map) {
		// TODO Auto-generated method stub

	}

	@Override
	public void showLoadMore(HashMap<String, AbsModule> map) {
		// TODO Auto-generated method stub

	}

	private void setList(ProductListInfo productListInfo) {
		shopProductList.clear();
		entertaimentProductList.clear();
		foodProductList.clear();
		lifeProductList.clear();
		for (int i = 0; i < productListInfo.getProdecuListDetail().size(); i++) {
			if ("1".equals(productListInfo.getProdecuListDetail().get(i)
					.getProductType())) {
				shopProductList.add(productListInfo.getProdecuListDetail().get(
						i));
			} else if ("2".equals(productListInfo.getProdecuListDetail().get(i)
					.getProductType())) {
				entertaimentProductList.add(productListInfo
						.getProdecuListDetail().get(i));
			} else if ("4".equals(productListInfo.getProdecuListDetail().get(i)
					.getProductType())) {
				foodProductList.add(productListInfo.getProdecuListDetail().get(
						i));
			} else if ("3".equals(productListInfo.getProdecuListDetail().get(i)
					.getProductType())) {
				lifeProductList.add(productListInfo.getProdecuListDetail().get(
						i));
			}
		}
		if (entertaimentProductList.size() > 0) {
			setEntertainmentValue(entertaimentProductList);
			number_entertainment.setText(entertaimentProductList.size() + "");
		} else {
			number_entertainment.setText("0");
		}
		if (foodProductList.size() > 0) {
			setFoodValue(foodProductList);
			number_food.setText(foodProductList.size() + "");
		} else {
			number_food.setText("0");
		}
		if (lifeProductList.size() > 0) {
			setLifeValue(lifeProductList);
			number_life.setText(lifeProductList.size() + "");
		} else {
			number_life.setText("0");
		}

		if (shopProductList.size() > 0) {
			setShopValue(shopProductList);
			number_shop.setText(shopProductList.size() + "");
		} else {
			number_shop.setText("0");
		}
	}

	@Override
	public void findView() {

		sv_myshopingmall = (ScrollView) view
				.findViewById(R.id.sv_my_shopingchange);
		back = (Button) view.findViewById(R.id.my_shopingchange_back);

		focusImage = (ImageView) view
				.findViewById(R.id.my_shopingchange_imfocus);
		refresh = (Button) view.findViewById(R.id.my_shopingchange_refresh);
		focusImage.setOnClickListener(this);
		refresh.setOnClickListener(this);
		shop_ll = (RelativeLayout) view
				.findViewById(R.id.brand_classification_shop_ll);
		entertaiment_ll = (RelativeLayout) view
				.findViewById(R.id.brand_classification_entertaiment_ll);
		life_ll = (RelativeLayout) view
				.findViewById(R.id.brand_classification_life_ll);
		food_ll = (RelativeLayout) view
				.findViewById(R.id.brand_classification_food_ll);

		shop_ll.setOnClickListener(click);
		entertaiment_ll.setOnClickListener(click);
		life_ll.setOnClickListener(click);
		food_ll.setOnClickListener(click);

		number_shop = (TextView) view.findViewById(R.id.brand_shopclass_number);
		number_entertainment = (TextView) view
				.findViewById(R.id.brand_entertainmentclass_number);
		number_food = (TextView) view.findViewById(R.id.brand_foodclass_number);
		number_life = (TextView) view.findViewById(R.id.brand_lifeclass_number);

		exchangeShopAction = new ExchangeShopAction();
		exchangeShopModule = new ExchangeShopModule();

	}

	@Override
	public void setOnClick() {

		back.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				int i = getFragmentManager().getBackStackEntryCount();
				if (i <= 1) {
					((ManagerActivity) getActivity()).promptExit(getActivity());
				} else {
					getFragmentManager().popBackStack();
				}

			}
		});

	}

}
